package io.mft.commons.db.mapper;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import io.mft.commons.db.mapper.Where.WhereType;
import lombok.EqualsAndHashCode;

@EqualsAndHashCode(callSuper=false)
public class TbWhere{

	private final List<Where> wheres=new ArrayList<>();
	private  final Map<String, Where> map=new HashMap<>();
	        /**
	 * @说明：TODO
	 * @字段名称 serialVersionUID
	        */  
	    
	
	
	private String tbName;
	
	public final static String Tb="TbWhere";
	
	public TbWhere(String tbName) {
		this.tbName=tbName;
	}

	public void addWhere(String field,WhereType whereType,Object value) {
		if (map.containsKey(field)) {
			return;
		}
		Where where=new Where();
		where.setField(field);
		where.setType(whereType);
		where.setValue(value);
		wheres.add(where);
	}
	public void set(String field,Object value) {
		addWhere(field, WhereType.eq, value);
	}

	public String getTbName() {
		return tbName;
	}

	public void setTbName(String tbName) {
		this.tbName = tbName;
	}

	public List<Where> getWheres() {
		return wheres;
	}

	public Map<String, Where> getMap() {
		return map;
	}
	
}
